/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package RegPack;

import DBManager.DBConnection;
import java.sql.*;
import DBManager.DBConnection;

/**
 *
 * @author maconcon
 */
public class RegManager {
    public boolean addManager(Register newManager)
    {
        boolean result = false;
        
        try{
            //get connection
            DBConnection db = new DBConnection();
            Connection conn =  db.getConnection();
            
          
            PreparedStatement pstmt =  conn.prepareStatement("call register"
                    + " (?,?,?,?,?,?,?,?,?,?,?,?,?)");
            
            //append values for the parameters
            int i = 1;
            pstmt.setString(i++, newManager.getUsername());
            pstmt.setString(i++, newManager.getPassword());
            pstmt.setString(i++, newManager.getAddress());
            pstmt.setString(i++, newManager.getCity());
            pstmt.setString(i++, newManager.getPostal());
            pstmt.setString(i++, newManager.getFirstname());
            pstmt.setString(i++, newManager.getMiddlename());
            pstmt.setString(i++, newManager.getLastname());
            pstmt.setString(i++, newManager.getEmail());
            pstmt.setString(i++, newManager.getCreditname());
            pstmt.setString(i++, newManager.getCreditnumber());
            pstmt.setString(i++, newManager.getExpdate());
            pstmt.setString(i++, newManager.getCredittype());

            //execute SQL statement
            pstmt.executeUpdate();
            
            result = true;
        }
        catch(SQLException ex){ex.printStackTrace();}
        
        return result;
    }
}
